'''
Created on 31.10.2012

@author: Michael
@brief: Contains the base Coordinate Class
'''

import uuid
import math

class Coordinate(object):
    """All other Antground objects inherit this base class."""
    def __init__(self, x, y, radius):
        self.x = x
        self.y = y
        self.radius = radius
        self.id = uuid.uuid4()

    def calculate_distance_between_centers(self, other):
        """Calculates the distance between the center of two coordinates."""
        deltax = abs(self.x - other.x)
        deltay = abs(self.y - other.y)
        return math.sqrt(deltax ** 2 + deltay ** 2)

    def calculate_distance(self, other):
        """Calculates the distance between two coordinates with radius."""
        distance = self.calculate_distance_between_centers(other)
        distance = distance - self.radius - other.radius
        if distance < 0:
            distance = 0
        return distance
